package bean;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;

/**
 * @Author 王志康
 * @Date 2021/9/6 16:44
 * @Version 1.0.0
 */
public class ItemBean {
    /**
     * itemName 商品名称
     * itemNumber 购买数量
     * itemPrice 单价价格
     * allPrice 总价格
     */
    private String itemName;
    private double itemNumber;
    private double itemPrice;
    private double allPrice;

    public ItemBean(String itemName, double itemNumber, double itemPrice) {
        this.itemName = itemName;
        this.itemNumber = itemNumber;
        this.itemPrice = itemPrice;
        BigDecimal num1 = new BigDecimal(itemPrice);
        BigDecimal num2 = new BigDecimal(itemNumber);
        BigDecimal allPrice=num1.multiply(num2);
        this.allPrice = allPrice.divide(new BigDecimal("1"),2, RoundingMode.HALF_UP).doubleValue();
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public double getItemNumber() {
        return itemNumber;
    }

    public void setItemNumber(double itemNumber) {
        this.itemNumber = itemNumber;
    }

    public double getItemPrice() {
        return itemPrice;
    }

    public void setItemPrice(double itemPrice) {
        this.itemPrice = itemPrice;
    }

    public double getAllPrice() {
        return allPrice;
    }

    public void setAllPrice(double allPrice) {
        this.allPrice = allPrice;
    }

    @Override
    public String toString() {
        return "产品名:" + itemName +
                " 购买数量:" + itemNumber +
                " 购买价格:" + itemPrice +
                " 总价格:" + allPrice;
    }
}
